package com.emode.service.impl;

import java.io.Serializable;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;
import com.emode.base.BaseDaoImpl;
import com.emode.base.Pager;
import com.emode.entity.Bbsreply;
import com.emode.service.ReplyService;

public class ReplyServiceImpl extends BaseDaoImpl<Bbsreply> implements ReplyService{
	//根据ID列出所有的 回复
	@Override
	public List listreply(Integer integer,Pager p) {
		String hql = "from Bbsreply r where rtid= ?";
		return PageQuery(hql, p,integer);
	}

	@Override
	@Transactional
	public void updateViewCount(Integer integer) {
		String sql = "update Bbsreply r set r.rclickcount =r.rclickcount+1 where r.rid= ";
		makeTransientByIds(sql,integer);
	}
	@Override
	public int countReply(Integer integer) {
		String hql = "select count(r)from Bbsreply r where rtid= ?";
		return getCount(hql,integer);
	}

	@Override
	public List<Bbsreply> getReplyByTime(Serializable id) {
		String whereHql = " and bbsusers.uid = ? order by o.rtime ";
		Object [] values = {id};
		return findObjectByConditionWithNoPage(whereHql, values);
	}
}
